const log4js = require('log4js');
const environment = require('../config/environment.config');

/**
 * 日志
 */
class Logger {
    constructor() {
        log4js.configure(require('../config/log4js.config'));
        this.data = this.getLogger('data');
        this.access = this.getLogger('access');
        this.error = this.getLogger('error');
        this.sql = this.getLogger('sql');
    }
    getLogger(category) {
        category = environment.isDev() ? 'console' : category;
        return log4js.getLogger(category);
    }
}

module.exports = global.buildClass(Logger);